﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ChengNet.StrongCaml.UnitTest
{
    [TestClass]
    public class CamlValueTest
    {
        [TestMethod]
        public void TestValueBoolean() {
            var val1 = Caml.Value(true);
            Assert.IsInstanceOfType(val1, typeof(Node.Value<ValueType.Boolean>));

            //var fail1 = Caml.Value<ValueType.Integer>(true);
        }

        [TestMethod]
        public void TestValueInteger() {
            var val1 = Caml.Value(5);
            Assert.IsInstanceOfType(val1, typeof(Node.Value<ValueType.Integer>));

            var val2 = Caml.Value<ValueType.Integer>(8);
            var val3 = Caml.Value<ValueType.Lookup>(5);
            var val4 = Caml.Value<ValueType.User>(3);

            //var fail1 = Caml.Value<ValueType.Text>(9);
            //var fail2 = Caml.Value<ValueType.Note>(2);
        }

        [TestMethod]
        public void TestValueString() {
            var val1 = Caml.Value("blah");
            Assert.IsInstanceOfType(val1, typeof(Node.Value<ValueType.Text>));

            var val2 = Caml.Value<ValueType.Text>("Hello");
            var val3 = Caml.Value<ValueType.Note>("World");
        }

        [TestMethod]
        public void TestValueDateTime() {
            var val1 = Caml.Value(DateTime.Now);
            Assert.IsInstanceOfType(val1, typeof(Node.Value<ValueType.DateTime>));

            var val2 = Caml.Value(Caml.Now());
            var val3 = Caml.Value(Caml.Today());
            var val4 = Caml.Value(Caml.Today(2));
        }

        [TestMethod]
        public void TestValueUser() {
            var val1 = Caml.Value(Caml.UserID());
            Assert.IsInstanceOfType(val1, typeof(Node.Value<ValueType.User>));

            var val2 = Caml.Value<ValueType.Lookup>(Caml.UserID());
            var val3 = Caml.Value<ValueType.Integer>(Caml.UserID());
            var val4 = Caml.Value<ValueType.User>(Caml.UserID());

            //var fail1 = Caml.Value<ValueType.Lookup>("string");
            //var fail2 = Caml.Value<ValueType.Lookup>(true);

        }
    }
}
